package com.myrslok.set;

import org.jetbrains.annotations.NotNull;

import java.io.File;

public class FileToFileResource implements SourceTargetResource<File, File> {

    @NotNull
    private final File source;
    @NotNull
    private final File target;

    public FileToFileResource(@NotNull final String source, @NotNull final String target) {
        this.source = new File(source);
        this.target = new File(target);
    }

    public FileToFileResource(@NotNull final File source, @NotNull final File target) {
        this.source = source;
        this.target = target;
    }

    @NotNull
    public File getSource() {
        return source;
    }

    @NotNull
    public File getTarget() {
        return target;
    }

    @SuppressWarnings({"ControlFlowStatementWithoutBraces", "RedundantIfStatement"})
    @Override
    public boolean equals(final Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final FileToFileResource that = (FileToFileResource) o;

        if (!source.equals(that.source)) return false;
        if (!target.equals(that.target)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = source.hashCode();
        result = 31 * result + target.hashCode();
        return result;
    }
}
